package org.boge.sharpdoc.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.boge.sharpdoc.dao.CareDao;
import org.boge.sharpdoc.bean.Care;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CareService {
    @Autowired
    private CareDao careDao;

    public boolean ifCared(Long self, Long other) {
        return careDao.findIfExist(self, other) != null;
    }

    public Integer removeCare(Long self, Long other) {
        return careDao.deleteCare(self, other);
    }

    public Integer addCare(Long self, Long other) {
        return careDao.addCare(self, other);
    }

    public PageInfo<Care> getOnesCare(Integer index, Integer pageSize, Long phone) {
        return PageHelper.startPage(index, pageSize).doSelectPageInfo(() -> careDao.findOnesCare(phone));
    }
}